package com.xidian.zhiancloud.service.myyb;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xidian.zhiancloud.dao.SysAnnounMapper;
import com.xidian.zhiancloud.model.SysAnnouncement;
import com.xidian.zhiancloud.model.SysAnnouncementExample;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IAnnounService extends ServiceImpl
        <SysAnnounMapper,SysAnnouncement> implements IService<SysAnnouncement>{

    @Autowired
    private SysAnnounMapper announcementMapper;

    public long countByExample(SysAnnouncementExample example) {
        return announcementMapper.countByExample(example);
    }

    public List<SysAnnouncement> selectByExampleWithRowbounds(SysAnnouncementExample example, RowBounds rowBounds) {
        return announcementMapper.selectByExampleWithRowbounds(
                example, rowBounds);
    }

    public SysAnnouncement selectByPrimaryKey(Long id) {
        return announcementMapper.selectByPrimaryKey(id);
    }

    public List<SysAnnouncement> getList( String title, int current, int size) {
        SysAnnouncementExample announcementExample = new SysAnnouncementExample();
        if (title != null) {
            announcementExample.getOredCriteria().get(0).andTitleEqualTo(title);
        }
        return announcementMapper.selectByExampleWithRowbounds(announcementExample,
                new RowBounds(current, size));
    }

}
